<template>
	<view class="appBox">
		<view class="j-bg">
			<view>
				<view class="txt txt1">
					<text>收益总额(元)</text>
					<text>星级</text>
				</view>
				<view class="txt txt2">
					<text>235267.00</text>
					<text>2级</text>
				</view>
			</view>
			<view class="txt txt1">
				<text>1星：10人</text>
				<text>2星：8人</text>
				<text>3星：5人</text>
			</view>
		</view>
		<!-- 收益记录 -->
		<view class="syjl">
			<text class="syjl-title">收益记录</text>
			<view class="syjl-item" v-for="item in 4" :key="item">
				<view class="item-left">
					<text class="left-title">1x</text>
					<text class="left-date">2024-03-08</text>
				</view>
				<view class="item-right">
					<text>2000</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	import sendVerifyCode from "@/mixins/SendVerifyCode";
	import Routine from '@/libs/routine';
	import {
		loginMobile,
		registerVerify,
		getCodeApi,
		getUserInfo,
		phoneSilenceAuth,
		phoneWxSilenceAuth
	} from "@/api/user";
	import {
		bindingPhone
	} from '@/api/api.js'
	import {
		getUserPhone
	} from '@/api/public';
	import mobileLogin from '@/components/login_mobile/index.vue'
	export default {
		name: 'login_mobile',
		data() {
			return {
				options: '',
				keyCode: '',
				account: '',
				codeNum: '',
				isUp: true,
				authKey: '',
				logoUrl: '',
				isShow: false,
				isPos: false,
				platform: '', // 手机平台
				appleShow: '' //是否是苹果登录

			}
		},
		components: {
			mobileLogin
		},
		mixins: [sendVerifyCode],
		mounted() {
			//this.getCode();
		},
		onLoad: function(options) {
			let that = this;
			// 获取系统信息
			uni.getSystemInfo({
				success(res) {
					that.platform = res.platform;
				}
			});
			const {
				code,
				state,
				scope,
				back_url,
				appleShow
			} = options;
			that.options = options
			if (options.authKey) that.authKey = options.authKey
			if (options.appleShow) that.appleShow = options.appleShow
		},
		methods: {
			wechatPhone() {
				this.$Cache.clear('snsapiKey');
				if (this.options.back_url) {
					let url = uni.getStorageSync('snRouter');
					url = url.indexOf('/pages/index/index') != -1 ? '/' : url;
					if (url.indexOf('/pages/users/wechat_login/index') !== -1) {
						url = '/';
					}
					if (!url) {
						url = '/pages/index/index';
					}
					this.isUp = false
					uni.showToast({
						title: '登录成功!',
						icon: 'none'
					})
					setTimeout(res => {
						location.href = url
					}, 800)
				} else {
					uni.navigateBack()
				}
			},
			// 获取验证码
			async code() {
				let that = this;
				if (!that.account) return that.$util.Tips({
					title: '请填写手机号码'
				});
				if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
					title: '请输入正确的手机号码'
				});
				await registerVerify(that.account).then(res => {
					that.$util.Tips({
						title: res.msg
					});
					that.sendCode();
				}).catch(err => {
					return that.$util.Tips({
						title: err
					})
				})
			},
			// 获取验证码api
			getCode() {
				let that = this
				getCodeApi().then(res => {
					that.keyCode = res.data.key;
				}).catch(res => {
					that.$util.Tips({
						title: res
					});
				});
			},
			close() {
				this.$emit('close', false)
			},
			// #ifdef MP
			phoneSilenceAuth(code) {
				let self = this
				phoneSilenceAuth({
					code: code,
					spid: app.globalData.spid,
					spread: app.globalData.code,
					phone: this.account,
					captcha: this.codeNum
				}).then(res => {
					this.$store.commit('LOGIN', {
						token: res.data.token
					});
					this.$store.commit("SETUID", res.data.uid);
					this.getUserInfo();
				}).catch(error => {
					self.$util.Tips({
						title: error
					})
				})
			},
			// #endif
			/**
			 * 获取个人用户信息
			 */
			getUserInfo: function() {
				let that = this;
				getUserInfo().then(res => {
					uni.hideLoading();
					that.userInfo = res.data
					that.$store.commit("UPDATE_USERINFO", res.data);
					// #ifdef MP
					that.$util.Tips({
						title: '登录成功',
						icon: 'success'
					}, {
						tab: 3
					})
					that.close()
					// #endif
					// #ifdef H5
					that.$emit('wechatPhone', true)
					// #endif
				});
			},
		}
	}
</script>

<style>
	page {
		height: 100%;
	}
</style>
<style lang="scss" scoped>
	.appBox {
		background-color: #F2F6FD;
		height: 100%;
		padding: 16rpx 33rpx;

		.j-bg {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			height: 285rpx;
			width: 100%;
			background: url('/static/images/j_bg.png') no-repeat;
			background-size: 100% 100%;
			padding: 39rpx 43rpx 31rpx 43rpx;

			.txt {
				display: flex;
				justify-content: space-between;
				color: white;

			}

			.txt1 {
				font-size: 22rpx;
			}

			.txt2 {
				font-size: 66rpx;
				font-weight: bold;
				margin-top: 15rpx;
			}
		}

		.syjl {
			.syjl-title {
				width: 120px;
				font-family: PingFang SC;
				font-weight: 400;
				font-size: 30rpx;
				color: #333333;
				margin-top: 33rpx;
				display: block;
			}

			.syjl-item {
				display: flex;
				justify-content: space-between;
				height: 114rpx;
				padding: 18rpx 22rpx 15rpx 21rpx;
				background: #fff;
				margin-top: 18rpx;

				.item-left {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					.left-title{
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 26rpx;
						color: #333333;
					}
					.left-date{
						font-family: PingFang SC;
						font-weight: 400;
						font-size: 22rpx;
						color: #999999;
						line-height: 30rpx;
					}
				}

				.item-right {
					color: #EA6D07;
					font-size: 26rpx;
				}
			}
		}
	}


	page {
		background-color: #fff !important;
	}
</style>